<template>
    <div>
      <h1>User Statistics</h1>
      <p>Total Users: {{ stats.totalUsers }}</p>
      <p>Admin Users: {{ stats.adminUsers }}</p>
      <p>Regular Users: {{ stats.regularUsers }}</p>
    </div>
  </template>
  
  <script>
  import axios from 'axios';
  
  export default {
    data() {
      return {
        stats: {
          totalUsers: 0,
          adminUsers: 0,
          regularUsers: 0,
        },
      };
    },
    async created() {
      await this.fetchStats();
    },
    methods: {
      async fetchStats() {
        try {
          const response = await axios.get('http://localhost:8080/api/v1/users/stats');
          this.stats = response.data;
        } catch (error) {
          console.error('Error fetching stats:', error);
        }
      },
    },
  };
  </script>
  
  <style scoped>
  /* 样式可以根据需要添加 */
  </style>
  